package com.zy.web.demo.shejimoshi.danli;

/**
 * @author <a href="mailto:zhouyong@cqyyt.com">zy</a>
 * @version 1.0
 * @date 2020/8/19 9:41
 * 双检锁/双重校验锁（DCL，即 double-checked locking）
 * 采用双重锁，能在多线程模式下保持高效率
 */
public class DanLi4 {

    private volatile static DanLi4 danLi4;

    public DanLi4(){};

    public static DanLi4 getInstance(){
        if (danLi4 == null){
            synchronized (DanLi4.class){
                if (danLi4 == null){
                    danLi4 = new DanLi4();
                }
            }
        }
        return danLi4;
    }

}
